#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1.4e7 + 5;
const int MOD = 1e9 + 7;

int n;
bool vis[N];
int primes[N], tot;
int ans[N];
ll fastpow(ll b, ll p) {
  ll res = 1;
  while (p) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
void init(int n) {
  vis[1] = 1, ans[1] = 1;
  rep(i, 2, n) {
    if (!vis[i]) primes[++tot] = i, ans[i] = fastpow(i, n);
    rep(j, 1, tot) {
      ll k = 1ll * primes[j] * i;
      if (k > n) break;
      vis[k] = 1;
      ans[k] = 1ll * ans[primes[j]] * ans[i] % MOD;
      if (i % primes[j] == 0) break;
    }
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  init(n);
  int res = 0;
  rep(i, 1, n) res ^= ans[i];
  cout << res;
  return 0;
}
